import java.util.ArrayList ;
import java.util.Arrays ;
import java.util.Scanner ;
class PersonOverride{
	private String name ;
	private boolean gender ;
	private int age ;
	public PersonOverride(String name, int age, boolean gender) {
		super();
		this.name = name;
		this.gender = gender;
		this.age = age;
	}
	public PersonOverride(){
		this(default, 1 , true) ;
	}
	public String toString() {
		return this.name + - + this.age + - + this.gender;
	}
	public boolean equals(String name , int age , boolean gender){
		if(this.name.equals(name) && this.age == age && this.gender == gender)
			return true ;
		else 
			return false ;
	}
}
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in) ;
		int n1 , n2 ;
		n1 = sc.nextInt() ;
		sc.nextLine() ;
		PersonOverride person1[] = new PersonOverride[n1] ;
		n2 = sc.nextInt() ;
		sc.nextLine() ;
		ArrayListPersonOverride person2 = new ArrayListPersonOverride();
		for (int i = 0; i  n2; i++) {
			int count ;
			PersonOverride person = new PersonOverride(sc.next(),sc.nextInt(),sc.hasNext());
			for (count = 0; count  n2; count++)
			{
				if(person.equals(person2))
					break ;
			}
			if(count == n2)
				person2.add(person) ;
		}
		for (int i = 0; i  person1.length; i++) {
			System.out.println(person1[i]);
		}
		for (int i = 0; i  person2.size(); i++) {
			System.out.println(person2.get(i));
		}
		System.out.println(person2.size());
		System.out.println(Arrays.toString(PersonOverride.class.getConstructors()));
	}
}